var zpeng = {
    //用户输入
    setGame: {
        //-----------------------------------就看这里----------------------------------------
        setCount: 15, //页面总数量
        //对应的声音
        setImg: [
           "1海唐.png"
            , "11周翔.png"
			, "21杜宇生对照实验.png"
			, "2泽腾.png"
			, "12赵云澜.png"
			, "32原野.png"
			, "4李万.png"
			, "5陆展亭.png"
			, "25萧牧庭.png"
			, "6单军.png"
			, "7淡语.png"
			, "97更新.png"
			, "8舒清风.png"
			, "9花楠.png"
			, "89东京梦华录.png"
			, "10徐立宴魑鬼.png"
			, "30何健飞.png"
			, "40九天.png"
			, "50孙俊伟.png"
			, "60严展万事如意.png"
			, "100荣光修斯.png"
			, "31宁觉非.png"
			, "51单鸣养父.png"
			, "111山口山日记.png"
			, "141回眸三生.png"
			, "22郝峻极限深潜.png"
			, "42易扬.png"
			, "62郁解放.png"
			, "112锦衣卫.png"
			, "3路程残烬.png"
			, "13邵均.png"
			, "23谢敏人间世.png"
			, "33沈少白.png"
			, "43达金.png"
			, "113土匪攻略.png"
			, "183过桥米线.png"
			, "14白泽春抄.png"
			, "24洛映白.png"
			, "34陈深.png"
			, "44与你相识.png"
			, "64盗号.png"
			, "144恰同学少年.png"
			, "15李世民且志凌烟.png"
			, "35方染.png"
			, "45头骨太太.png"
			, "26骆逸凡绝密委托.png"
			, "36文彬.png"
			, "46沈灿.png"
			, "56罗伊斯.png"
			, "96二十三道门.png"
			, "27沈长乐.png"
			, "37萧霖.png"
			, "47刘地.png"
			, "18商鞅战国杀.png"
			, "28盖志辉.png"
			, "38秦伟路.png"
			, "48韩谦.png"
			, "29梁上君最终流放.png"
			, "39野也.png"
			, "49谢林.png"
			, "59柳易尘.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
            // , "1海唐.png"
            // , "2泽腾.png"
            // , "3路程.png"
        ],
        //对应的声音
        setWordSound: [
           "1海唐.mp3"
            , "11周翔.mp3"
			, "21杜宇生对照实验.mp3"
			, "2泽腾.mp3"
			, "12赵云澜.mp3"
			, "32原野.mp3"
			, "4李万.mp3"
			, "5陆展亭.mp3"
			, "25萧牧庭.mp3"
			, "6单军.mp3"
			, "7淡语.mp3"
			, "97更新.mp3"
			, "8舒清风.mp3"
			, "9花楠.mp3"
			, "89东京梦华录.mp3"
			, "10徐立宴魑鬼.mp3"
			, "30何健飞.mp3"
			, "40九天.mp3"
			, "50孙俊伟.mp3"
			, "60严展万事如意.mp3"
			, "100荣光修斯.mp3"
			, "31宁觉非.mp3"
			, "51单鸣养父.mp3"
			, "111山口山日记.mp3"
			, "141回眸三生.mp3"
			, "22郝峻极限深潜.mp3"
			, "42易扬.mp3"
			, "62郁解放.mp3"
			, "112锦衣卫.mp3"
			, "3路程残烬.mp3"
			, "13邵均.mp3"
			, "23谢敏人间世.mp3"
			, "33沈少白.mp3"
			, "43达金.mp3"
			, "113土匪攻略.mp3"
			, "183过桥米线.mp3"
			, "14白泽春抄.mp3"
			, "24洛映白.mp3"
			, "34陈深.mp3"
			, "44与你相识.mp3"
			, "64盗号.mp3"
			, "144恰同学少年.mp3"
			, "15李世民且志凌烟.mp3"
			, "35方染.mp3"
			, "45头骨太太.mp3"
			, "26骆逸凡绝密委托.mp3"
			, "36文彬.mp3"
			, "46沈灿.mp3"
			, "56罗伊斯.mp3"
			, "96二十三道门.mp3"
			, "27沈长乐.mp3"
			, "37萧霖.mp3"
			, "47刘地.mp3"
			, "18商鞅战国杀.mp3"
			, "28盖志辉.mp3"
			, "38秦伟路.mp3"
			, "48韩谦.mp3"
			, "29梁上君最终流放.mp3"
			, "39野也.mp3"
			, "49谢林.mp3"
			, "59柳易尘.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
            // , "1海唐.mp3"
            // , "2泽腾.mp3"
            // , "3路程.mp3"
        ],
        //显示在荷叶上的东西 -- 需要顺序保持一致。
        setWord: [
           "1海唐.mp3"
            , "11周翔.mp3"
			, "21杜宇生对照实验.mp3"
			, "2泽腾.mp3"
			, "12赵云澜.mp3"
			, "32原野.mp3"
			, "4李万.mp3"
			, "5陆展亭.mp3"
			, "25萧牧庭.mp3"
			, "6单军.mp3"
			, "7淡语.mp3"
			, "97更新.mp3"
			, "8舒清风.mp3"
			, "9花楠.mp3"
			, "89东京梦华录.mp3"
			, "10徐立宴魑鬼.mp3"
			, "30何健飞.mp3"
			, "40九天.mp3"
			, "50孙俊伟.mp3"
			, "60严展万事如意.mp3"
			, "100荣光修斯.mp3"
			, "31宁觉非.mp3"
			, "51单鸣养父.mp3"
			, "111山口山日记.mp3"
			, "141回眸三生.mp3"
			, "22郝峻极限深潜.mp3"
			, "42易扬.mp3"
			, "62郁解放.mp3"
			, "112锦衣卫.mp3"
			, "3路程残烬.mp3"
			, "13邵均.mp3"
			, "23谢敏人间世.mp3"
			, "33沈少白.mp3"
			, "43达金.mp3"
			, "113土匪攻略.mp3"
			, "183过桥米线.mp3"
			, "14白泽春抄.mp3"
			, "24洛映白.mp3"
			, "34陈深.mp3"
			, "44与你相识.mp3"
			, "64盗号.mp3"
			, "144恰同学少年.mp3"
			, "15李世民且志凌烟.mp3"
			, "35方染.mp3"
			, "45头骨太太.mp3"
			, "26骆逸凡绝密委托.mp3"
			, "36文彬.mp3"
			, "46沈灿.mp3"
			, "56罗伊斯.mp3"
			, "96二十三道门.mp3"
			, "27沈长乐.mp3"
			, "37萧霖.mp3"
			, "47刘地.mp3"
			, "18商鞅战国杀.mp3"
			, "28盖志辉.mp3"
			, "38秦伟路.mp3"
			, "48韩谦.mp3"
			, "29梁上君最终流放.mp3"
			, "39野也.mp3"
			, "49谢林.mp3"
			, "59柳易尘.mp3"

            // , "3路程6"
            // , "1海唐7"
            // , "2泽腾8"
            // , "3路程9"
            // , "1海唐10"
            // , "2泽腾11"
            // , "3路程12"
            // , "1海唐13"
            // , "2泽腾14"
            // , "3路程15"
            // , "1海唐16"
            // , "2泽腾17"
            // , "3路程18"
            // , "1海唐19"
            // , "2泽腾20"
            // , "3路程21"
            // , "1海唐22"
            // , "2泽腾23"
            // , "3路程24"
        ],

    },
    //-------------------------------------下面的都不用看-----------------------------------------------------------------------------
    //静态数据 -  只生成设置一次
    bodyHeight: 480,
    bodyWidth: 560,
    moveTime: 24,
    moveFlag: false,
    audio: "声音对象",
    canvas: "画布对象",
    passDiv: "我希望包括我自己，包括大家，还是能够继续保持对配音对网配圈的热情还有喜爱",
    canGame: true,
    clickLock: false,
    //动态数据 - 每次游戏开始设置一次
    word: [],
    wordSound: [],
    wordChouse: "随机数",
    ball: [],
    backImg: [],

    // 静态数据生成
    innit: function () {
        //创建声音实例
        zpeng.audio = document.createElement("audio");
        zpeng.audioSys = document.createElement("audio");
        //画布
        zpeng.canvas = document.createElement("div");
        zpeng.canvas.id = "cvas";
        zpeng.canvas.className = "cvas";
        zpeng.bodyHeight = parseInt(document.body.clientHeight || document.documentElement.clientHeight);
        zpeng.bodyWidth = parseInt(document.body.clientWidth || document.documentElement.clientWidth);
        zpeng.canvas.style.position = "fixed";
        zpeng.canvas.style.top = zpeng.bodyHeight / 2 + "px";
        zpeng.canvas.style.left = zpeng.bodyWidth / 2 + "px";
        zpeng.canvas.style.margin = "-" + (zpeng.bodyHeight / 2) + "px 0px 0px -" + (zpeng.bodyWidth / 2) + "px";
        zpeng.canvas.style.height = zpeng.bodyHeight + "px";
        zpeng.canvas.style.width = zpeng.bodyWidth + "px";
        zpeng.canvas.style.backgroundRepeat = "no-repeat";
        document.body.appendChild(zpeng.canvas);
        //朗读
        var cvaBt = document.createElement("div");
        cvaBt.id = "z_button";
        cvaBt.value = "read angin";
        cvaBt.style.position = "absolute";
        cvaBt.style.width = "100px";
        cvaBt.style.height = "80px";
        cvaBt.style.top = "100%";
        cvaBt.style.left = "100%";
        cvaBt.style.margin = "-81px 0px 0px -101px";
        zpeng.canvas.appendChild(cvaBt);
        cvaBt.onclick = function () {
            zpeng.audio.play();
        }
        //大家好我是乘风归去
        zpeng.passDiv = document.createElement("div");
        zpeng.passDiv.id = "passDiv";
        zpeng.passDiv.className = "passDiv";
        zpeng.passDiv.style.position = "fixed";
        zpeng.passDiv.style.top = zpeng.bodyHeight / 2 + "px";
        zpeng.passDiv.style.left = zpeng.bodyWidth / 2 + "px";
        zpeng.passDiv.style.margin = "-" + (zpeng.bodyHeight / 2) + "px 0px 0px -" + (zpeng.bodyWidth / 2) + "px";
        zpeng.passDiv.style.height = zpeng.bodyHeight + "px";
        zpeng.passDiv.style.width = zpeng.bodyWidth + "px";
        document.body.appendChild(zpeng.passDiv);
        var passDivdiv = document.createElement("div");
        passDivdiv.style.margin = (zpeng.bodyHeight / 2 - 100) + "px 0px 40px 0px";
        passDivdiv.innerHTML = "我希望包括我自己，包括大家，还是能够继续保持对配音对网配圈的热情还有喜爱!";
        zpeng.passDiv.appendChild(passDivdiv);
        var passDivBt = document.createElement("input");
        passDivBt.type = "button";
        passDivBt.value = "大家好，我是乘风归去！";
        passDivBt.onclick = function () {
            zpeng.restarGame();
            zpeng.passDiv.style.display = "none";
        }
        zpeng.passDiv.appendChild(passDivBt);


    },
    //动态数据生成
    innitDong: function (count) {

        zpeng.setNewBall(count);
        //判断是否可以开始游戏
        if (zpeng.canGame) {
            //开始游戏
            var myload = document.createElement("div");
            myload.id = "main_timeBack";
            myload.style.position = "fixed";
            myload.style.top = "0px";
            myload.style.left = "0px";
            myload.style.height = zpeng.bodyHeight + "px";
            myload.style.width = zpeng.bodyWidth + "px";
            myload.style.background = "#fff";
            myload.style.zIndex = 10020;
            var myloadH2 = document.createElement("h2");
            myloadH2.style.position = "absolute";
            myloadH2.innerHTML = "大家好~我是~乘风归去";
            myloadH2.style.width = zpeng.bodyWidth + "px";
            myloadH2.style.fontSize = "50px"
            myloadH2.style.textAlign = "center";
            myloadH2.style.top = zpeng.bodyHeight / 2 + "px";
            myloadH2.style.left = zpeng.bodyWidth / 2 + "px";
            myloadH2.style.margin = "-120px 0px 0px -" + zpeng.bodyWidth / 2 + "px";
            myloadH2.onclick = function () {
                myload.style.animation = "kt_timeBack2 0.5s ease-out both";
                setTimeout(() => {
                    document.body.removeChild(myload);
                    zpeng.playAudio();
                }, 500);
            }
            myload.appendChild(myloadH2);
            document.body.appendChild(myload);
            myload.style.animation = "kt_timeBack 0.5s ease-out both";
            zpeng.canGame = false; //false时候表示游戏中。
        }
        else {
            zpeng.passDiv.style.display = "block";
            zpeng.passDiv.childNodes[0].innerHTML = "屏幕过小，无法进行该考题。";
            zpeng.passDiv.childNodes[1].style.display = "none";
            //   zpeng.passDiv.innerHTML = "屏幕过小无法进行该考题";

        }
    },

    setNewBall: function (count) {
        //获取用户输入，设置游戏单词和声音  注意：setWord用来控制库存，word用来控制游戏中数量。
        if (zpeng.setGame.setWord.length < count) {
            count = zpeng.setGame.setWord.length;
        }
        for (var i = (count - 1); i >= 0; i--) {
            zpeng.word.push(zpeng.setGame.setWord[i]);
            zpeng.setGame.setWord.splice(i, 1); //通过这个来控制数量

        }

        for (var i = (count - 1); i >= 0; i--) {
            zpeng.wordSound.push(zpeng.setGame.setWordSound[i]);
            zpeng.setGame.setWordSound.splice(i, 1); //通过这个来控制数量

        }
        for (var i = (count - 1); i >= 0; i--) {
            zpeng.backImg.push(zpeng.setGame.setImg[i]);
            zpeng.setGame.setImg.splice(i, 1); //通过这个来控制数量
        }

        //根据数组生成球
        //用于检测屏幕是否可以进行游戏
        var setTop = 1;
        var setLeft = 1;
        var setLMax = 0;
        //生成球
        let flagStart = zpeng.word.length - 1;    //为了控制从数组末尾开始，引入这个临时变量。
        for (var i = (count - 1); i >= 0; i--) {
            zpeng.word[flagStart] = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + zpeng.word[flagStart] + "&nbsp;"; //给word旁边+俩空格。
            zpeng.ball[flagStart] = document.createElement("div");

            zpeng.ball[flagStart].innerHTML = zpeng.word[flagStart];
            zpeng.ball[flagStart].style.background = "white url(img/" + zpeng.backImg[flagStart] + ")  center center no-repeat";
            zpeng.ball[flagStart].style.backgroundSize = "100%";
            zpeng.ball[flagStart].z_movePoint = zpeng.random(1, 1);
            zpeng.ball[flagStart].isPeng = ""; //与之发生碰撞对象的ID
            zpeng.canvas.appendChild(zpeng.ball[flagStart]);
            zpeng.ball[flagStart].moveWay = zpeng.random(4, 1);
            zpeng.ball[flagStart].className = "ball chuxianDonghua";
            switch (zpeng.ball[flagStart].moveWay) {
                case 1:
                    zpeng.ball[flagStart].z_moveTop = true;
                    zpeng.ball[flagStart].z_moveLeft = true;
                    break;
                case 2:
                    zpeng.ball[flagStart].z_moveTop = true;
                    zpeng.ball[flagStart].z_moveLeft = false;
                    break;
                case 3:
                    zpeng.ball[flagStart].z_moveTop = false;
                    zpeng.ball[flagStart].z_moveLeft = true;
                    break;
                case 4:
                    zpeng.ball[flagStart].z_moveTop = false;
                    zpeng.ball[flagStart].z_moveLeft = false;
                    break;
            }


            zpeng.ball[flagStart].style.width = "90px";
            zpeng.ball[flagStart].style.height = "90px";
            // zpeng.ball[flagStart].style.height = zpeng.ball[flagStart].offsetWidth + "px";
            zpeng.ball[flagStart].style.lineHeight = zpeng.ball[flagStart].style.height;
            zpeng.ball[flagStart].canMove = true;

            zpeng.ball[flagStart].onclick = function () {
                if (!zpeng.clickLock) {
                    if (zpeng.trim(this.innerHTML) == zpeng.word[zpeng.wordChouse]) {
                        //回答正确
                        zpeng.audioSys.src = "./sound/sysSound/that's_right it's_me.mp3";
                        zpeng.audioSys.play();
                        this.canMove = false;
                        this.className = "ball sureDonghua";
                        setTimeout(() => {
                            if (zpeng.word.length > 0) {

                                zpeng.word.splice(zpeng.wordChouse, 1);//用一个移除一个
                                zpeng.wordSound.splice(zpeng.wordChouse, 1);
                                zpeng.backImg.splice(zpeng.wordChouse, 1);
                                zpeng.canvas.removeChild(zpeng.ball[zpeng.wordChouse]);
                                zpeng.ball.splice(zpeng.wordChouse, 1);
                                zpeng.playAudio();
                                if (zpeng.word.length == 0) {
                                    zpeng.playAudio("./sound/sysSound/我希望包括我自己，包括大家，还是能够继续保持对配音对网配圈的热情还有喜爱.mp3")
                                    zpeng.passDiv.style.display = "block";
                                    zpeng.canGame = true;//可以再开始游戏
                                }
                                if (zpeng.setGame.setWord.length > 0) {
                                    zpeng.setNewBall(1);
                                }
                                zpeng.clickLock = false; //解锁
                            }
                        }, 1000);
                    }
                    else {
                        zpeng.audioSys.src = "./sound/sysSound/脑子瓦特了.mp3";
                        zpeng.audioSys.play();
                        this.canMove = false;
                        this.className = "ball misDonghua";
                        setTimeout(() => {
                            this.className = "ball";
                            this.canMove = true;
                            zpeng.clickLock = false; //解锁
                            zpeng.audio.play();
                        }, 2000);
                    }
                    zpeng.clickLock = true; //点了就锁定，一秒后解锁
                }
            }
            //生成球以后，设置位置位置。
            //初始位置一路设置下去用这写法：
            // var ofw = parseInt(zpeng.ball[flagStart].offsetWidth);
            // var ofh = parseInt(zpeng.ball[flagStart].offsetHeight);
            // if (ofh > setLMax) {
            //     setLMax = ofh;
            // }
            // setLeft = setLeft + ofw + 5;
            // if (setLeft + ofw >= zpeng.bodyWidth) {
            //     setLeft = 1;
            //     setTop = setTop + setLMax + 5;
            //     setLMax = 0;
            //     if (setTop + ofh >= zpeng.bodyHeight) {
            //         zpeng.canGame = false;
            //         break;
            //     }
            // }
            //初始位置随机设置用这写法(高度宽度)：
            setTop = zpeng.random(1, zpeng.bodyHeight);
            if (setTop + parseInt(zpeng.ball[flagStart].offsetHeight) + 10 > zpeng.bodyHeight) {
                setTop = setTop - parseInt(zpeng.ball[flagStart].offsetHeight);
            }
            setLeft = zpeng.random(1, zpeng.bodyWidth);
            if (setLeft + parseInt(zpeng.ball[flagStart].offsetWidth) + 10 > zpeng.bodyWidth) {
                setLeft = setLeft - parseInt(zpeng.ball[flagStart].offsetWidth);
            }
            zpeng.ball[flagStart].style.top = setTop + "px";
            zpeng.ball[flagStart].style.left = setLeft + "px";

            //这个要减减，为了控制从数组末尾开始。
            flagStart--;
        }
    }
    ,
    ballmove: function () {
        // if (zpeng.canGame) {
        //获取成临时变量，方便使用
        var bb = zpeng.ball;
        var ts = zpeng;
        var wd = zpeng.word;
        var mflag = zpeng.moveFlag;
        //消息循环
        setInterval(function () {
            //碰撞检测
            for (var i = 0; i < bb.length; i++) {
                var bb1ban = parseInt(bb[i].offsetWidth) / 2;  //球1半径
                var bb1zhY = parseInt(bb[i].style.top) + bb1ban; //球1中点Y
                var bb1zhX = parseInt(bb[i].style.left) + bb1ban; //球1中点X
                for (var j = i; j < bb.length; j++) {
                    if (bb[i].id != bb[j].id) {
                        var bb2ban = parseInt(bb[j].offsetWidth) / 2;  //球2半径
                        var bb2zhY = parseInt(bb[j].style.top) + bb2ban; //球2中点Y
                        var bb2zhX = parseInt(bb[j].style.left) + bb2ban; //球2中点X
                        var bbXcha = Math.abs(bb2zhX - bb1zhX); //X差
                        var bbYcha = Math.abs(bb2zhY - bb1zhY); //Y差
                        var bbXju = parseInt(Math.sqrt(bbXcha * bbXcha + bbYcha * bbYcha)); //圆心距离
                    }
                    if (bbXju <= (bb1ban + bb2ban) + 2) {   // 发生碰撞
                        if (bbXcha >= bbYcha) {   //碰撞位置
                            if (bb[i].z_moveLeft == bb[j].z_moveLeft) {
                                if (bb1zhY < bb1zhY) {
                                    bb[i].z_moveTop = true;
                                    bb[j].z_moveTop = false;
                                }
                                else {
                                    bb[i].z_moveTop = false;
                                    bb[j].z_moveTop = true;
                                }
                            }
                            else if (bb1zhX < bb1zhX) {
                                bb[i].z_moveLeft = true;
                                bb[j].z_moveLeft = false;

                            }
                            else {

                                bb[i].z_moveLeft = false;
                                bb[j].z_moveLeft = true;
                            }
                        }
                        else {

                            if (bb[i].z_moveLeft == bb[j].z_moveLeft) {
                                if (bb1zhX < bb1zhX) {
                                    bb[i].z_moveLeft = true;
                                    bb[j].z_moveLeft = false;
                                }
                                else {

                                    bb[i].z_moveLeft = false;
                                    bb[j].z_moveLeft = true;
                                }
                            }
                            else if (bb1zhY < bb1zhY) {
                                bb[i].z_moveTop = true;
                                bb[j].z_moveTop = false;
                            }
                            else {
                                bb[i].z_moveTop = false;
                                bb[j].z_moveTop = true;
                            }
                        }
                    }
                }
                //移动+碰边
                var bi = bb[i];
                var bitop = parseInt(bi.style.top);
                var bileft = parseInt(bi.style.left);
                var biwidth = parseInt(bi.offsetWidth);
                var biheight = parseInt(bi.style.height);
                if (bi.canMove) {
                    if (bi.z_moveTop && bi.z_moveLeft) {
                        bi.style.top = bitop + bi.z_movePoint + "px";
                        bi.style.left = bileft + bi.z_movePoint + "px";
                        if (bitop + biheight + bi.z_movePoint >= ts.bodyHeight) {
                            bi.z_moveTop = false;
                        }
                        if (bileft + biwidth + bi.z_movePoint >= ts.bodyWidth) {
                            bi.z_moveLeft = false;
                        }
                    }
                    else if (!bi.z_moveTop && bi.z_moveLeft) {
                        bi.style.top = bitop - bi.z_movePoint + "px";
                        bi.style.left = bileft + bi.z_movePoint + "px";
                        if (bitop <= 0) {
                            bi.z_moveTop = true;
                        }
                        if (bileft + biwidth + bi.z_movePoint >= ts.bodyWidth) {
                            bi.z_moveLeft = false;
                        }
                    }
                    else if (bi.z_moveTop && !bi.z_moveLeft) {
                        bi.style.top = bitop + bi.z_movePoint + "px";
                        bi.style.left = bileft - bi.z_movePoint + "px";
                        if (bitop + biheight + bi.z_movePoint >= ts.bodyHeight) {
                            bi.z_moveTop = false;
                        }
                        if (bileft <= 0) {
                            bi.z_moveLeft = true;
                        }
                    }
                    else if (!bi.z_moveTop && !bi.z_moveLeft) {
                        bi.style.top = bitop - bi.z_movePoint + "px";
                        bi.style.left = bileft - bi.z_movePoint + "px";
                        if (bitop <= 0) {
                            bi.z_moveTop = true;
                        }
                        if (bileft <= 0) {
                            bi.z_moveLeft = true;
                        }
                    }
                }
            }
        }, zpeng.moveTime);
        // }
    },
    playAudio: function (link) {
        if (link) {
            zpeng.audio.src = link;
            zpeng.audio.play();
        }
        else if (zpeng.word.length > 0) {         //创建随机数并朗读
            zpeng.wordChouse = zpeng.random(zpeng.word.length - 1, 0); //创建随机选中周铁
            zpeng.audio.src = "./sound/" + zpeng.wordSound[zpeng.wordChouse];
            zpeng.audio.play();
        }
    },
    //生成随机数（max,min）
    random: function (a, b) {
        return Math.floor(Math.random() * (a - b + 1) + b);
    },
    //去空格
    trim: function (str) {
        return str.replace(/(^\s*)|(\s*$)/g, "");
    },
    //动画结束监听
    anBack: function (element, type, callback) {
        var pfx = ["webkit", "moz", "MS", "o", ""];
        for (var p = 0; p < pfx.length; p++) {
            if (!pfx[p]) type = type.toLowerCase();
            element.addEventListener(pfx[p] + type, callback, false);
        }
    },


    restarGame: function () {

        //重新开始游戏的语音
        zpeng.playAudio("./sound/sysSound/大家好我是乘风归去.mp3");

        //清空动态数据，重新生成
        for (var i = 0; i < zpeng.ball.length; i++) {
            zpeng.ball[i].parentNode.removeChild(zpeng.ball[i]);
        }
        zpeng.word.splice(0, zpeng.word.length);
        zpeng.wordSound.splice(0, zpeng.wordSound.length);
        zpeng.wordChouse = 0;
        zpeng.ball.splice(0, zpeng.ball.length);

        //重新拿回初始设置
        for (let tt in zpeng.linWord) {
            zpeng.setGame.setWord.push(zpeng.linWord[tt]);
        }
        for (let tt in zpeng.linImg) {
            zpeng.setGame.setImg.push(zpeng.linImg[tt]);
        }
        for (let tt in zpeng.linSound) {
            zpeng.setGame.setWordSound.push(zpeng.linSound[tt]);
        }
        zpeng.innitDong(zpeng.setGame.setCount);
    },
    linWord: [], //临时用来保留预设，一遍游戏过程丢失。
    linImg: [],
    linSound: [],
    gamestart: function () {
        for (let tt in zpeng.setGame.setWord) {
            zpeng.linWord.push(zpeng.setGame.setWord[tt]);
        }
        for (let tt in zpeng.setGame.setImg) {
            zpeng.linImg.push(zpeng.setGame.setImg[tt]);
        }
        for (let tt in zpeng.setGame.setWordSound) {
            zpeng.linSound.push(zpeng.setGame.setWordSound[tt]);
        }
        this.innit();
        this.innitDong(zpeng.setGame.setCount);
        //开启消息循环
        zpeng.ballmove();

    },
};